/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package meteocal.business.boundary;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import meteocal.business.entity.BadWeather;
import meteocal.business.entity.Event;

/**
 *
 * @author luana
 */
@Stateless
public class BadWeatherFacade extends AbstractFacade<BadWeather> {
    
    @PersistenceContext
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public BadWeatherFacade() {
        super(BadWeather.class);
    }
    
    public void create(Event idEvent, String category) {
        BadWeather bad_weather = new BadWeather();
        bad_weather.setIdEvent(idEvent);
        bad_weather.setWeatherCategory(category);
        
        
        em.persist(bad_weather);
        
       
        
        
    }
    
    public List<BadWeather> findInBad(Event idEvent, String category) {
        
    return em.createNamedQuery(BadWeather.FIND_BAD_EVENT, BadWeather.class)
                            .setParameter("weatherCategory", category)
                            .setParameter("idEvent", idEvent)
                            .getResultList();
     }
    
    
    
    
}
